home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13023 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: solon.com!not-for-mail
  2. From: ferguson@col.hp.com (Scott Ferguson)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Followup-To: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  6. Date: 3 Apr 1996 19:04:47 -0600
  7. Organization: HP Colorado Springs Division
  8. Sender: clc@solutions.solon.com
  9. Approved: clc@solutions.solon.com
  10. Message-ID: <4jv77f$cu8@solutions.solon.com>
  11. References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j41ru$nq4@solutions.solon.com> <4jttlq$3p1@solutions.solon.com>
  12. NNTP-Posting-Host: solutions.solon.com
  13. X-Newsreader: TIN [version 1.2 PL2]
  14.  
  15. I would hope by now that HP's C compiler has a fairly good degree of 
  16. optimization built in, to the point that most cases of this:
  17.  
  18. for (i=0;i<n;i++) x[i] = y[i]*z[i];
  19.  
  20. should perform as quickly as:
  21.  
  22. xp = x;
  23. yp = y;
  24. zp = z;
  25. endp = &x[n];
  26.  
  27. while (xp < endp) *(xp++) = (*yp++) * (*zp++);
  28.  
  29. In my former life, I worked on supercomputers, and the ONLY way to get
  30. decent performance out of C code was to use arrays whenever possible, 
  31. otherwise the compiler which was built to maximize use of available 
  32. hardware acceleration could tell what you were trying to do. So where
  33. do our compilers stand on this? If PA-RISC has some superscalar ops like
  34. multiply-add in a single clock, I'd rather give the compiler enough high-level
  35. language to optimize to what's best for the hardware.
  36.  
  37. I haven't worked with HP's C enough to know. If you already hashed this
  38. out while I wasn't reading the thread, sorry.
  39.  
  40.  
  41. --
  42. -----------------------------------------------------------------------------
  43. Scott Ferguson                                             Solely my opinions
  44. Hewlett-Packard Co.                                      Colorado Springs, CO
  45. ftp://col.hp.com/html/ferguson/index.html
  46.